package com.hnao.hnserialport

import android.os.Bundle
import android.view.KeyEvent
import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity
import com.hnao.serialport.SerialPortScanKeyManager

class MainActivity : AppCompatActivity() {

    private val tv by lazy { findViewById<TextView>(R.id.tv) }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)

        (application as App).setListener {
            tv.text = it
        }
    }

    override fun dispatchKeyEvent(event: KeyEvent?): Boolean {
        return SerialPortScanKeyManager.dispatchKeyEvent(event) ?: super.dispatchKeyEvent(event)
    }

//    override fun onStart() {
//        super.onStart()
//        SerialPortHidManager.initHID(this)
//    }
//
//    override fun onStop() {
//        super.onStop()
//        SerialPortHidManager.closeHID()
//    }
}